<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="find.name">
                    </td>
                </tr>

                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="find.pwd" >
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" @click="DL">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';
import { useInfoStore } from '@/stores/info';
import { useRouter } from 'vue-router';


var infos=useInfoStore();
var touerr=useRouter();

//登录
const find=ref({
    name:"",
    pwd:""
})

//登录
const DL=()=>{
    axios.get("https://localhost:7165/api/DL/Getdl",{params:find.value}).then(res=>{
        if(res.data.Id==-1){
            alert("用户名不存在");
            return;
        }

        if(res.data.Id==-2){
            alert("密码错误");
            return;
        }

        if(res.data.Id>0){
            alert("登录成功");
            infos.find.name=find.value.name;//pinia存
            touerr.push({path:"/"})
        }
    })
}


</script>

<style scoped>

</style>